﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

using DataService;
using DTO;

public partial class Devices_devicesdetails :BasePage
{
   private DeviceService _service;
    private IList<Device> _devices;
    private IList<Device> _devicesfirewall;
    private IList<Device> _devicesOther;
    public Devices_devicesdetails()
    {
        _service = new DeviceService();
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (UserLogin == null)
        {
            Response.Redirect("~/Login.aspx");
        }
        if (string.IsNullOrEmpty(Request.QueryString["Deviceid"]))
        {
            Response.Redirect("default.aspx");
        }
        else
        {
            hplEditSever.NavigateUrl += Request.QueryString["Deviceid"];
        }
        if (!IsPostBack)
        {
            LoadGrid();
        }
    }

    private void LoadGrid()
    {
        //device chi 1
        _devices = _service.GetListDeviceByAccountIdAndDeviceId(UserLogin.Customer.Id,Convert.ToInt32(Request.QueryString["Deviceid"]),"D", false);
        dlDevices.DataSource = _devices;
        dlDevices.DataBind();

        //firewall
        _devicesfirewall = _service.GetListDeviceByAccountIdAndDeviceId(UserLogin.Customer.Id, Convert.ToInt32(Request.QueryString["Deviceid"]), "F", false);
        dlFirewall.DataSource = _devicesfirewall;
        dlFirewall.DataBind();

        //other khac device current
        _devicesOther = _service.GetListDeviceByAccountIdAndDeviceId(UserLogin.Customer.Id, Convert.ToInt32(Request.QueryString["Deviceid"]), _devices[0].DeviceIdType, true);
        dlDeviceOther.DataSource = _devicesOther;
        dlDeviceOther.DataBind();

    }

}